<template>
	<z-paging ref="paging" v-model="list" @query="queryList">
		<view v-for="(item, index) in list" :key="index" class="card">
			<view class="content">{{ item.countent }}</view>
			<view class="date">{{ item.createtime }}</view>
		</view>
	</z-paging>
</template>

<script>
import { changeLog, changeLogRoom } from '@/api/landlord.js'
export default {
	data() {
		return {
			list: [],
			roomId: 0,
			type: 2,
		}
	},
	onLoad(options) {
		if (typeof options.room_id !== 'undefined') {
			console.log(options)
			this.roomId = options.room_id
			this.type = options.type || 2
		}
	},
	methods: {
		queryList(pageNo, pageSize) {
			if (this.type == 1) {
				changeLog({
					page: pageNo,
					page_size: pageSize,
					id: this.roomId
				})
					.then((res) => {
						console.log(res)
						this.$refs.paging.complete(res.data.data.data)
					})
					.catch((res) => {
						this.$refs.paging.complete(false)
					})
			} else {
				changeLogRoom({
					page: pageNo,
					page_size: pageSize,
					id: this.roomId
				})
					.then((res) => {
						console.log(res)
						this.$refs.paging.complete(res.data.data.data)
					})
					.catch((res) => {
						this.$refs.paging.complete(false)
					})
			}

		}
	}
}
</script>

<style lang="scss" scoped>
.card {
	box-sizing: border-box;
	width: 95%;
	margin: 30rpx auto;
	box-sizing: border-box;
	padding: 20rpx;
	background: #fff;
	border-radius: 15rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;

	.content {
		width: calc(100% - 210rpx);
		margin-right: 10rpx;
		height: auto;
		word-wrap: break-word;
		word-break: break-all;
		white-space: normal;
	}

	.date {
		font-size: 24rpx;
		width: 200rpx;
	}
}
</style>
